//
//  JBJMainViewController.m
//  BaojieWeiBo02
//
//  Created by user on 15/10/4.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "JBJMainViewController.h"
#import "JBJTabBar.h"
@interface JBJMainViewController ()

@property (nonatomic,strong) NSMutableArray *navs;
@property (weak, nonatomic) IBOutlet JBJTabBar *mainTabBar;

@end

@implementation JBJMainViewController

- (NSMutableArray *)navs{
    if (!_navs) {
        _navs = [NSMutableArray array];
    }
    return _navs;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar.tintColor = [UIColor orangeColor];
    
    UINavigationController *Home = [self addchileViewControllerWithString:@"Home" title:@"首页" imageName:@"tabbar_home"];
    UINavigationController *Message = [self addchileViewControllerWithString:@"Message" title:@"消息" imageName:@"tabbar_message_center"];
    UINavigationController *Discover = [self addchileViewControllerWithString:@"Discover" title:@"发现" imageName:@"tabbar_discover"];
    UINavigationController *Profile = [self addchileViewControllerWithString:@"Profile" title:@"我" imageName:@"tabbar_profile"];
    
    self.viewControllers = @[Home,Message,Discover,Profile];
    
    [self.mainTabBar.composeButton addTarget:self action:@selector(composeDidClick) forControlEvents:UIControlEventTouchUpInside];
    // Do any additional setup after loading the view.
}

-(void)composeDidClick{
    NSLog(@"haha");
}

- (UINavigationController *)addchileViewControllerWithString:(NSString *)sbName title:(NSString *)title imageName:(NSString *)imageName{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:sbName bundle:nil];
    
    UINavigationController *nav = [sb instantiateInitialViewController];
    
    nav.topViewController.title = title;
    
    nav.tabBarItem.image = [UIImage imageNamed:imageName];
    
    return nav;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
